{php include wl_template('common/header');}
<link rel="stylesheet" href="{URL_MODULE}web/resource/diy/css/diy.min.css">
<ul class="nav nav-tabs">
    <li class="active"><a href="javascript:;">菜单管理</a></li>
</ul>
<div class="app-content">
    <div class="app-filter">
        <div class="filter-action">
            <a href="{php echo web_url($edit,array('menu_class'=>$menuClass));}"  class="btn btn-primary">新建菜单</a>
        </div>
        <div class="filter-list">
            <form class="form-horizontal" action="" method="post">
                <div class="form-group">
                    <div class="col-sm-2 control-label">菜单名称</div>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" name="name" value="{$name}" placeholder="请输入菜单名称">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-2 control-label"></div>
                    <div class="col-sm-6">
                        <div class="input-group">
                            <button class="btn btn-primary" type="submit" >搜索</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="app-table-list">
        <div class="table-responsive">
            <table class="table table-hover table-bordered">
                <thead class="navbar-inner">
                <tr>
                    <th width="20%" class="text-center">菜单名称</th>
                    <th width="20%" class="text-center">创建时间</th>
                    <th width="20%" class="text-center">最后修改时间</th>
                    <th width="20%" class="text-center">操作</th>
                </tr>
                </thead>
                <tbody>
                {loop $list $index $item}
                <tr class="text-center">
                    <td>{$item['name']}</td>
                    <td>{php echo date('Y-m-d H:i:s', $item['createtime'])}</td>
                    <td>{php echo date('Y-m-d H:i:s', $item['lastedittime'])}</td>
                    <td>
                        {if $item['aid'] == $_W['aid'] || (empty($_W['aid']) && !empty($item['is_public'])) }
                            <a class="btn btn-sm btn-primary" href="{php echo web_url($edit, array('id'=>$item['id'],'menu_class'=>$item['menu_class']))}">编辑</a>
                            <a class="btn btn-sm btn-danger" data-toggle="ajaxRemove" href="{php echo web_url('diy/diy/delMenu', array('id'=>$item['id']))}" data-confirm="确定要删除该自定义菜单吗？">删除</a>
                            {if !empty($item['aid'])}
<!--                            <a class="btn btn-sm btn-default menuSetPulbic" data-href="{php echo web_url('diypage/diyset/pageSetPublic',array('id'=>$item['id'],'type'=>3))}" is_public="{$item['is_public']}">{if $item['is_public'] == 1}设为私有菜单{else}设为公共菜单{/if}</a>-->
                            {/if}
                        {else}
                            <a class="btn btn-sm btn-info" style="background-color:darkgrey;border: 0" href="javascript:;">无操作项</a>
                        {/if}
                    </td>
                </tr>
                {/loop}
                </tbody>
            </table>
        </div>
        <div class="app-table-foot clearfix">
			<div class="pull-left">
			</div>
			<div class="pull-right">
				{$pager}
			</div>
		</div>
    </div>
</div>
<script>
    //将页面设置为公共页面
    $(".menuSetPulbic").on('click',function () {
        var the = $(this);
        var url = the.data("href");
        var is_public = the.attr("is_public");
        var tips = '确定要将该页面设为公共菜单吗？设置后每个代理商都可以使用该菜单';
        if(is_public == 1){
            tips = '确定要将该页面设为私有菜单吗？设置后其他代理商将不可使用该菜单';
        }
        tip.confirm(tips,function () {
            $.post(url,function (res) {
                if(res.errno == 1){
                    the.html("设为公共菜单");
                    {if empty($_W['aid'])}
                    location.reload();
                    {/if}
                }else{
                    the.html("设为私有菜单");
                }
            },'json');
        });
    });
</script>
{php include wl_template('common/footer');}